class Solution:
    def isPowerOfTwo(self, n: int) -> bool:
        mid_str = bin(n)[2:]
        if mid_str.startswith("1") and mid_str.count("1") == 1:
            return True
        return False


a = Solution()
print(a.isPowerOfTwo(8))
print(a.isPowerOfTwo(1))
